﻿#ifndef AVT_VMBAPI_EXAMPLES_APICONTROLLER
#define AVT_VMBAPI_EXAMPLES_APICONTROLLER

#include <string>
#include <VimbaCPP/Include/VimbaCPP.h>
#include "VimbaApi/CameraObserver.h"
#include "VimbaApi/FrameObserver.h"

namespace AVT {
namespace VmbAPI {
namespace Examples {

class ApiController
{
public:
    ApiController();
    ~ApiController();

    VmbErrorType        StartUp();

    void                ShutDown();

    VmbErrorType GetFeatureIntValue(const std::string &featureName, VmbInt64_t & value);

    VmbErrorType SetFeatureIntValue(const std::string &featureName, VmbInt64_t value);

    VmbErrorType GetFeatureDoubleValue(const std::string &featureName, double & value);

    VmbErrorType SetFeatureDoubleValue(const std::string &featureName, double value);

    VmbErrorType        StartContinuousImageAcquisition();

    VmbErrorType        StopContinuousImageAcquisition();

    int                 GetWidth();

    int                 GetHeight();

    VmbPixelFormatType  GetPixelFormat() const;

    CameraPtrVector     GetCameraList();

    FramePtr            GetFrame();

    VmbErrorType        QueueFrame( FramePtr pFrame );

    void                ClearFrameQueue();

    QObject*            GetCameraObserver();

    QObject*            GetFrameObserver();

    std::string         ErrorCodeToMessage( VmbErrorType eErr ) const;

    std::string         GetVersion() const;
    bool SetInternalMode(int mode);
    VmbErrorType OpenCameraF(const std::string &rStrCameraID);
    void CloseCamerF();
private:
    // A reference to our Vimba singleton
    VimbaSystem&                m_system;
    // The currently streaming camera
    CameraPtr                   m_pCamera;
    // Every camera has its own frame observer
    IFrameObserverPtr           m_pFrameObserver;
    // Our camera observer
    ICameraListObserverPtr      m_pCameraObserver;
    // The current pixel format
    VmbInt64_t                  m_nPixelFormat;
    // The current width
    VmbInt64_t                  m_nWidth;
    // The current height
    VmbInt64_t                  m_nHeight;
    // camera open?
    bool						m_bCamera;
public:
    int m_nCameraMode = 0; // 0 硬触发  2 自由模式
};
}}} // namespace AVT::VmbAPI::Examples

#endif
